package tree;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class isSameTree {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null){
            return true;
        }
        return commpare(p,q);
    }
    public boolean commpare(TreeNode p, TreeNode q){
        if (p == null && q == null){
            return true;
        }
        if (p == null && q != null){
            return false;
        }
        if (p != null && q == null){
            return false;
        }
        if (p.val != q.val){
            return false;
        }
        boolean outside = commpare(p.left, q.left);
        boolean inside = commpare(p.right, q.right);
        return outside && inside;
    }
}
